/*
 * @Author: lemon 1534860242@qq.com
 * @Date: 2025-07-28 13:43:46
 * @LastEditors: lemon 1534860242@qq.com
 * @LastEditTime: 2025-08-12 11:50:28
 * @FilePath: /xby-edu/nuxt.config.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
// https://nuxt.com/docs/api/configuration/nuxt-config
import { defineNuxtConfig } from "nuxt/config";
// import { resolve } from "pathe";
import fg from "fast-glob";
export default defineNuxtConfig({
  compatibilityDate: "2025-07-15",
  devtools: { enabled: true },
  modules: [
    "@unocss/nuxt",
    "@nuxtjs/sitemap",
    "@nuxtjs/robots",
    "@nuxt/image", // 图片体积/格式自动优化，提升 LCP
    "@nuxtjs/i18n",
  ],
  i18n: {
    // 路由策略：默认语言不加前缀，其它语言加前缀
    strategy: "prefix_except_default",
    // 懒加载语言包（推荐，体积小）
    lazy: true,
    langDir: "locales",
    defaultLocale: "zh",
    detectBrowserLanguage: {
      // 用 cookie 记住选择
      useCookie: true,
      cookieKey: "i18n_locale",
      redirectOn: "root", // 仅在根路径重定向
    },
    // 你支持的语言
    locales: [
      { code: "zh", iso: "zh-CN", name: "简体中文", file: "zh.json" },
      { code: "en", iso: "en-US", name: "English", file: "en.json" },
      { code: "es", iso: "es-ES", name: "Español", file: "es.json" },
    ],
    // 数字/日期格式化（可选）
    // vueI18n: "./i18n.config.ts",
  },
  // 站点根地址（用于 canonical、OG、Sitemap 生成）
  site: { url: "https://www.aecti.com", name: "西班牙科技创新院（西科院）" },
  sitemap: {
    autoLastmod: true,
    defaults: { changefreq: "weekly", priority: 0.7 },
  },

  robots: {
    rules: [{ userAgent: "*", allow: "/", disallow: ["/admin", "/draft"] }],
    sitemap: ["https://www.aecti.com/sitemap.xml"],
  },

  plugins: [
    // 引入 sticky header 插件
    "~/plugins/sticky-header.client.ts",
  ],
  css: [
    "~/assets/styles/main.less",
    "~/assets/css/plugins/bootstrap.min.css",
    "~/assets/fonts/font-awesome.min.css",
    "~/assets/fonts/flaticon/flaticon.css",
    "~/assets/css/plugins/slick.css",
    "~/assets/css/style.css",
    "~/assets/css/responsive.css",
  ],
  // hooks: {
  //   async "pages:extend"(pages) {
  //     const files = await fg("pages/**/*.vue", { cwd: __dirname });
  //     for (const file of files) {
  //       const routeName = file
  //         .replace(/^pages\//, "")
  //         .replace(/\.vue$/, "")
  //         .replace(/\/index$/, ""); // 把 course/index.vue 转成 course
  //       pages.push({
  //         name: `${routeName.replace(/\//g, "-")}-html`,
  //         path: `/${routeName}.html`,
  //         file: resolve(__dirname, file),
  //       });
  //     }
  //   },
  // },
  app: {
    head: {
      link: [{ rel: "stylesheet", href: "/css/slick.css" }],
      script: [
        { src: "/js/jquery-3.6.0.min.js", tagPosition: "bodyClose" },
        { src: "/js/slick.min.js", tagPosition: "bodyClose" },
        { src: "/js/jquery.counterup.min.js", tagPosition: "bodyClose" },
        { src: "/js/jquery.inview.min.js", tagPosition: "bodyClose" },
        { src: "/js/bootstrap.bundle.min.js", tagPosition: "bodyClose" },
        { src: "/js/anime.min.js", tagPosition: "bodyClose" },
        // { src: "/js/custom.js", tagPosition: "bodyClose" },
        // { src: "/js/jquery.validate.min.js", tagPosition: "bodyClose" },
      ],
    },
  },
  routeRules: {},
  runtimeConfig: {
    // 仅服务端可见
    apiSecret: "",
    // 客户端也可见的配置
    public: {
      baseURL: process.env.NUXT_PUBLIC_API_BASE,
      baseURLSSR: process.env.NUXT_PUBLIC_API_BASE || "https://api.example.com",
      siteUrl: "https://www.aecti.com",
      siteName: "西班牙科技创新院（西科院）",
      defaultOG: "/og/cover-home.jpg",
    },
  },
  typescript: { strict: true },
});
